$(document).ready(function () {
    queryMarkChecks();
});

//教师无条件查询全部成绩复查申请

var queryMarkChecks = function () {
    //alert("-----")
    $('#dataTable').dataTable({
        "bDeferRender": true,
        "sAjaxDataProp": "data.markCheckList",
        "sAjaxSource": "http://localhost:8080/markCheck/queryAllMarkChecks",
        "sPaginationType": "bs_full", //"bs_normal", "bs_two_button", "bs_four_button", "bs_full"
        "fnPreDrawCallback": function (oSettings) {
            $('.dataTables_filter input').addClass('form-control input-large').attr('placeholder', 'Search！');
            $('.dataTables_length select').addClass('form-control input-small');
        },
        "oLanguage": {
            "sSearch": "",
            "sLengthMenu": "<span>_MENU_ entries</span>"
        },
        "bJQueryUI": false,
        "bAutoWidth": false,
        "sDom": "<'row'<'col-lg-6 col-md-6 col-sm-12 text-center'l><'col-lg-6 col-md-6 col-sm-12 text-center'f>r>t<'row-'<'col-lg-6 col-md-6 col-sm-12'i><'col-lg-6 col-md-6 col-sm-12'p>>",
        "aoColumns": [
            {"mDataProp": "applyRecheckid"},
            {"mDataProp": "stuId"},
            {"mDataProp": "stuName"},
            {"mDataProp": "courseName"},
            {"mDataProp": "markId"},
            {"mDataProp": "mark"},
            {"mDataProp": "rescoreTime"},
            {
                "mDataProp": "rescoreState",
                "mRender": function (data) {
                    if (data == 2) {
                        return "<span  class='badge badge-danger mr10 mb10'>已核实，成绩无误</span>";
                    }
                    if (data == 1) {
                        return "<span  class='badge badge-info mr10 mb10'>已核实，成绩有误且已修正</span>";
                    }
                    if (data == 0) {
                        return "<a href='#'><span  class='label label-danger mr10 mb10'  id='handle'>查看</span></a>"
                            + "<a href='#'><span class='label label-success mr10 mb10'  onclick=\"reloadPage()\" id='right'>核实无误</span></a>"
                            + "<a href='#'><span class='label label-success mr10 mb10'  onclick=\"reloadPage()\" id='wrong'>核实有误已修改</span></a>";
                    }
                }
            }
        ],
    })
};

//老师核实学生成绩复查申请，结果无误
$(document).on('click', '#right', function () {
    //获取成绩复查申请记录的编号ID:$MarkCheckId
    var $MarkCheckId = $(this).parents("tr").children(0).eq(0).text();
    // var $stuApplyId = $(this).parents("tr").children(0).eq(0);
    alert("-----" + $MarkCheckId);
    $.ajax({
        url: "http://localhost:8080/markCheck/markCheckHandel",
        type: "GET",
        // async: true,
        // "projectId=" + projectId+"&projectState=1",
        data: "markCheckId=" + $MarkCheckId + "&updateState=2",
        dataType: "json",
        success: function () {
            //query();//问题：不能自动刷新
            layer.alert("操作成功!");
        },
        error: function () {
            layer.alert("操作失败!");
        }
    });
});

//点击同意或拒绝的同时刷新页面

function reloadPage() {
    window.location.reload();
}

//老师核实学生成绩复查申请，成绩有误且已修改
$(document).on('click', '#wrong', function () {
    //获取成绩复查申请记录的编号ID:$MarkCheckId
    var $MarkCheckId = $(this).parents("tr").children(0).eq(0).text();
    alert("-----" + $MarkCheckId);
    $.ajax({
        url: "http://localhost:8080//markCheck/markCheckHandel",
        type: "GET",
        // async: true,
        data: "markCheckId=" + $MarkCheckId + "&updateState=1",
        dataType: "json",
        success: function () {
            //query();
            layer.alert("操作成功!");
        },
        error: function () {
            layer.alert("操作失败--!");
        }
    });
});









